module.exports = app =>{
    const { INTEGER,DATE,STRING } = app.Sequelize;
    const Feedback = app.model.define('feedback', {
        id: {
          type: INTEGER(20),
          primaryKey: true,
          allowNull: false,
          defaultValue: 0,
          comment: '自增ID',
        },
        informerId: {
            type: INTEGER,
            allowNull: false,
            defaultValue: 0,
            comment: '举报人ID',
            references: {
              model: 'user',
              key: 'id'
            },
            onDelete: 'cascade',
            onUpdate: 'restrict', // 更新时操作
        },
        reportedId: {
            type: INTEGER(20),
            allowNull: false,
            defaultValue: 0,
            comment: "被举报人ID",
        },
        content: {
            type: STRING(600),
            allowNull: false,
            defaultValue: '',
            comment: "举报内容",
        },
        type: {
            type: INTEGER(2),
            allowNull: false,
            defaultValue: 0,
            comment: "举报类型",
        },
        check:{
            type: INTEGER,
            allowNull: false,
            defaultValue: 0,
            comment: "是否受理",
        },
        created_time: {
            type:DATE
        },
        updated_time:{
            type:DATE
        }
    });
    // 关联关系
    Feedback.associate = function (models) {
        // 关联用户
        Feedback.belongsTo(app.model.User,{foreignKey:'informerId',targetKey:'id'});
    }

    return Feedback;
}